package exercise;

class Solution6 {
    public int[] twoSum(int[] price, int target) {
        int l = 0, r = price.length-1;

        while (price[l] + price[r] != target) {
            int sum = price[l] + price[r];
            if (sum < target) {
                l++;
            } else {
                r--;
            }
        }

        return new int[]{price[l], price[r]};
    }
}